home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / sdk / vfw11.win / vfwdk / dialogs.c_ / dialogs.bin
Encoding:
Text File  |  1993-11-19  |  22.7 KB  |  549 lines

  1. /****************************************************************************
  2.  *
  3.  *   dialogs.c: Code for dialog procs of CapTest Sample Program
  4.  * 
  5.  *   Microsoft Video for Windows Capture Class Test Program
  6.  *
  7.  ***************************************************************************/
  8. /**************************************************************************
  9.  *
  10.  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  11.  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  12.  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  13.  *  PURPOSE.
  14.  *
  15.  *  Copyright (c) 1992, 1993  Microsoft Corporation.  All Rights Reserved.
  16.  * 
  17.  **************************************************************************/
  18.  
  19. #include <windows.h>
  20. #include <commdlg.h>
  21. #include <mmsystem.h>
  22. #include <msvideo.h>
  23. #include <mmreg.h>
  24. #include <io.h>
  25. #include <fcntl.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <memory.h>
  29. #include <dos.h>
  30.  
  31. #include <avicap.h>
  32. #include "captest.h"
  33.  
  34. static long GetFreeDiskSpace(WORD) ;
  35. static int  CountMCIDevices(WORD) ;
  36.  
  37. //
  38. // AboutProc: About Dialog Box Procedure
  39. //
  40. int FAR PASCAL AboutProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
  41. {
  42.     switch (Message) {
  43.         case WM_INITDIALOG :
  44.              return TRUE ;
  45.  
  46.         case WM_COMMAND :
  47.             switch (wParam) {
  48.                 case IDOK :
  49.                     EndDialog(hDlg, TRUE) ;
  50.                     return TRUE ;
  51.  
  52.                 case IDCANCEL :
  53.                     EndDialog(hDlg, FALSE) ;
  54.                     return TRUE ;
  55.             }
  56.             break ;
  57.     }
  58.  
  59.     return FALSE ;
  60. }
  61.  
  62.  
  63. //
  64. // AudioFormatProc: Audio Format Setting Dialog Box Procedure
  65. //
  66. int FAR PASCAL AudioFormatProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
  67. {
  68.     static int                nChannels ;
  69.     static WORD               wSample ;
  70.     static DWORD              dwFrequency ;
  71.  
  72.     switch (Message) {
  73.         case WM_INITDIALOG :
  74.             nChannels = IDD_ChannelIDs + glpwfex->nChannels ;
  75.             CheckRadioButton(hDlg, IDD_ChannelMono, IDD_ChannelStereo, nChannels) ;
  76.             wSample = IDD_SampleIDs + glpwfex->wBitsPerSample / 8 ;
  77.             CheckRadioButton(hDlg, IDD_Sample8Bit, IDD_Sample16Bit, wSample) ;
  78.             dwFrequency = IDD_FreqIDs + glpwfex->nSamplesPerSec / 11025 ;
  79.             CheckRadioButton(hDlg, IDD_Freq11kHz, IDD_Freq44kHz, (WORD)dwFrequency) ;
  80.             return TRUE ;
  81.  
  82.         case WM_COMMAND :
  83.             switch (wParam) {
  84.                 case IDOK :
  85.                     if (IsDlgButtonChecked(hDlg, IDD_ChannelMono))
  86.                         nChannels = 1 ;
  87.                     else
  88.                         if (IsDlgButtonChecked(hDlg, IDD_ChannelStereo))
  89.                             nChannels = 2 ;
  90.                         else {
  91.                             MessageBeep(MB_ICONEXCLAMATION) ;
  92.                             return FALSE ;
  93.                         }
  94.                         
  95.                     if (IsDlgButtonChecked(hDlg, IDD_Sample8Bit))
  96.                         wSample = 8 ;
  97.                     else
  98.                         if (IsDlgButtonChecked(hDlg, IDD_Sample16Bit))
  99.                             wSample = 16 ;
  100.                         else {
  101.                             MessageBeep(MB_ICONEXCLAMATION) ;
  102.                             return FALSE ;
  103.                         }
  104.  
  105.                     if (IsDlgButtonChecked(hDlg, IDD_Freq11kHz))
  106.                         dwFrequency = 11025 ;
  107.                     else
  108.                         if (IsDlgButtonChecked(hDlg, IDD_Freq22kHz))
  109.                             dwFrequency = 22050 ;
  110.                         else
  111.                             if (IsDlgButtonChecked(hDlg, IDD_Freq44kHz))
  112.                                 dwFrequency = 44100 ;
  113.                             else {
  114.                                 MessageBeep(MB_ICONEXCLAMATION) ;
  115.                                 return FALSE ;
  116.                             }
  117.  
  118.                     // All the entries verfied OK -- save them now
  119.                     glpwfex->nChannels = nChannels ;
  120.                     glpwfex->wBitsPerSample = wSample ;
  121.                     glpwfex->nSamplesPerSec = dwFrequency ;
  122.                     glpwfex->nBlockAlign =  glpwfex->nChannels * (glpwfex->wBitsPerSample / 8) ;
  123.                     glpwfex->nAvgBytesPerSec = (long) glpwfex->nSamplesPerSec *
  124.                                                       glpwfex->nBlockAlign ;
  125.                     glpwfex->cbSize = 0 ;
  126.                     glpwfex->wFormatTag = WAVE_FORMAT_PCM ;
  127.                     EndDialog(hDlg, TRUE) ;
  128.                     return TRUE ;
  129.  
  130.                 case IDCANCEL :
  131.                     EndDialog(hDlg, FALSE) ;
  132.                     return TRUE ;
  133.             }
  134.             break ;
  135.     }
  136.  
  137.     return FALSE ;
  138. }
  139.  
  140.  
  141. //
  142. // GetFreeDiskSpace: Function to Measure Available Disk Space
  143. //
  144. static long GetFreeDiskSpace(WORD wDrive) 
  145. {
  146.     static struct _diskfree_t DiskInfo ;
  147.  
  148.     // Use C function to get the disk info
  149.     if (_dos_getdiskfree(wDrive, &DiskInfo)) {
  150.         MessageBox(NULL, "Can't measure free disk space.", "Error",
  151. #ifdef BIDI
  152.                MB_RTL_READING |
  153. #endif
  154.                MB_OK | MB_ICONINFORMATION) ;
  155.         return -1L ;
  156.     }
  157.     return ( (long) DiskInfo.avail_clusters * 
  158.              (long) DiskInfo.sectors_per_cluster *
  159.              (long) DiskInfo.bytes_per_sector ) ;
  160. }
  161.  
  162.  
  163. //
  164. // AllocCapFileProc: Capture file Space Allocation Dialog Box Procedure
  165. //
  166. int FAR PASCAL AllocCapFileProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
  167. {
  168.     static WORD      wFreeMBs = 0 ;
  169.  
  170.     switch (Message) {
  171.         case WM_INITDIALOG :
  172.         {
  173.             int              fh ;
  174.             long             lFileSize = 0 ;
  175.             long             lFreeSpace ;
  176.             static char      achCapFile[100] ;
  177.  
  178.             // Get current capture file name and measure its size
  179.             capFileGetCaptureFile(ghWndCap, achCapFile, sizeof(achCapFile)) ;
  180.             if ((fh = _open(achCapFile, _O_RDONLY)) != -1) {
  181.                 if ((lFileSize = _lseek(fh, 0L, SEEK_END)) == -1L) {
  182.                     MessageBox(NULL, "Couldn't find size of current capture file",
  183.                                 "Error",
  184. #ifdef BIDI
  185.                 MB_RTL_READING |
  186. #endif
  187.  
  188.                     MB_OK | MB_ICONEXCLAMATION) ;
  189.                     lFileSize = 0 ;
  190.                 }
  191.                 _close(fh) ;
  192.             }
  193.  
  194.             // Get free disk space and add current capture file size to that.
  195.             // Convert the available space to MBs.
  196.             if ((lFreeSpace = GetFreeDiskSpace(0)) != -1L) {
  197.                 lFreeSpace += lFileSize ;
  198.                 wFreeMBs = (WORD)(lFreeSpace / ONEMEG) ;
  199.                 SetDlgItemInt(hDlg, IDD_SetCapFileFree, wFreeMBs, TRUE) ;
  200.             }
  201.             else {
  202.                 MessageBox(NULL, "Couldn't find out the free disk space",
  203.                            "Error",
  204. #ifdef BIDI
  205.                 MB_RTL_READING |
  206. #endif
  207.  
  208.                 MB_OK | MB_ICONEXCLAMATION) ;
  209.                 // shouldn't we disable the "free space" dlg item ?
  210.             }
  211.  
  212.             SetDlgItemInt(hDlg, IDD_SetCapFileSize, gwCapFileSize, TRUE) ;
  213.             return TRUE ;
  214.         }
  215.  
  216.         case WM_COMMAND :
  217.             switch (wParam) {
  218.                 case IDOK :
  219.                 {
  220.                     int         iCapFileSize ;
  221.  
  222.                     iCapFileSize = (int) GetDlgItemInt(hDlg, IDD_SetCapFileSize, NULL, TRUE) ;
  223.                     if (iCapFileSize <= 0 || (WORD)iCapFileSize > wFreeMBs) {
  224.                         // You are asking for more than we have !! Sorry, ...
  225.                         SetDlgItemInt(hDlg, IDD_SetCapFileSize, iCapFileSize, TRUE) ;
  226.                         SetFocus(GetDlgItem(hDlg, IDD_SetCapFileSize)) ;
  227.                         MessageBeep(MB_ICONEXCLAMATION) ;
  228.                         return FALSE ;
  229.                     }
  230.                     gwCapFileSize = iCapFileSize ;
  231.  
  232.                     EndDialog(hDlg, TRUE) ;
  233.                     return TRUE ;
  234.                 }
  235.  
  236.                 case IDCANCEL :
  237.                     EndDialog(hDlg, FALSE) ;
  238.                     return TRUE ;
  239.             }
  240.             break ;
  241.     }
  242.  
  243.     return FALSE ;
  244.  
  245. }
  246.  
  247.  
  248. //
  249. // MakePaletteProc: Palette Details Dialog Box Procedure
  250. //
  251. BOOL CALLBACK MakePaletteProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
  252. {
  253.     switch (Message) {
  254.         case WM_INITDIALOG :
  255.             SetDlgItemInt(hDlg, IDD_MakePalColors, gwPalColors, FALSE) ;
  256.             SetDlgItemInt(hDlg, IDD_MakePalFrames, gwPalFrames, FALSE) ;
  257.             return TRUE ;
  258.  
  259.         case WM_COMMAND :
  260.             switch (wParam) {
  261.                 case IDOK :
  262.                 {
  263.                     int         iColors ;
  264.                     int         iFrames ;
  265.  
  266.                     iColors = (int) GetDlgItemInt(hDlg, IDD_MakePalColors, NULL, TRUE) ;
  267.                     if (! (iColors > 0 && iColors <= 236 || iColors == 256)) {
  268.                         // invalid number of palette colors
  269.                         SetDlgItemInt(hDlg, IDD_MakePalColors, iColors, TRUE) ;
  270.                         SetFocus(GetDlgItem(hDlg, IDD_MakePalColors)) ;
  271.                         MessageBeep(MB_ICONEXCLAMATION) ;
  272.                         return FALSE ;
  273.                     }
  274.                     iFrames = (int) GetDlgItemInt(hDlg, IDD_MakePalFrames, NULL, TRUE) ;
  275.                     if (iFrames <= 0 || iFrames > 10000) {
  276.                         // no frame or way t-o-o many frames !!!
  277.                         SetDlgItemInt(hDlg, IDD_MakePalFrames, iFrames, TRUE) ;
  278.                         SetFocus(GetDlgItem(hDlg, IDD_MakePalFrames)) ;
  279.                         MessageBeep(MB_ICONEXCLAMATION) ;
  280.                         return FALSE ;
  281.                     }
  282.                     gwPalColors = iColors ;
  283.                     gwPalFrames = iFrames ;
  284.  
  285.                     EndDialog(hDlg, TRUE) ;
  286.                     return TRUE ;
  287.                 }
  288.  
  289.                 case IDCANCEL :
  290.                     EndDialog(hDlg, FALSE) ;
  291.                     return TRUE ;
  292.             }
  293.             break ;
  294.     }
  295.  
  296.     return FALSE ;
  297.  
  298. }
  299.  
  300.  
  301. //
  302. // CountMCIDevices: Function to Find the Number of MCI Devices of a Type
  303. //
  304. static int CountMCIDevices(WORD wType)
  305. {
  306.     int               nTotal = 0 ;
  307.     DWORD             dwCount ;
  308.     MCI_SYSINFO_PARMS mciSIP ;
  309.  
  310.     mciSIP.dwCallback = NULL ;
  311.     mciSIP.lpstrReturn = (LPSTR)(LPVOID) &dwCount ;
  312.     mciSIP.dwRetSize = sizeof(DWORD) ;
  313.     mciSIP.wDeviceType = wType ;
  314.    
  315.     // Use an MCI command to get the info
  316.     if (! mciSendCommand(NULL, MCI_SYSINFO, MCI_SYSINFO_QUANTITY,
  317.                          (DWORD)(LPVOID) &mciSIP))
  318.         nTotal = (int) *((LPDWORD) mciSIP.lpstrReturn) ;
  319.  
  320.     return nTotal ;
  321. }
  322.  
  323.  
  324. //
  325. // CapSetUpProc: Capture SetUp Details Dialog Box Procedure
  326. //
  327. int FAR PASCAL CapSetUpProc(HWND hDlg, UINT Message, UINT wParam, LONG lParam)
  328. {
  329.     BOOL            fValue ;
  330.     static char     achBuffer[21] ;
  331.  
  332.     switch (Message) {
  333.         case WM_INITDIALOG :
  334.         {
  335.             WORD        wValue ;
  336.  
  337.             // Convert from MicroSecPerFrame to FPS -- that's easier !!
  338.             wValue = (int) (1E+6 / gCapParms.dwRequestMicroSecPerFrame + 0.5) ;
  339.             SetDlgItemInt(hDlg, IDD_FrameRateData, wValue, FALSE) ;
  340.             if (gCapParms.fAbortLeftMouse)
  341.                 wValue = IDD_AbortLeftFlag ;
  342.             else
  343.                 if (gCapParms.fAbortRightMouse)
  344.                     wValue = IDD_AbortRightFlag ;
  345.                 else
  346.                     wValue = 0 ;  // none of the mouse-buttons !!!
  347.             CheckRadioButton(hDlg, IDD_AbortLeftFlag, IDD_AbortRightFlag, wValue) ;
  348.  
  349.             if (gCapParms.vKeyAbort == VK_ESCAPE)
  350.                 wValue = IDD_AbortEscFlag ;
  351.             else
  352.                 if (gCapParms.vKeyAbort == VK_SPACE)
  353.                     wValue = IDD_AbortSpaceFlag ;
  354.                 else
  355.                     if (gCapParms.vKeyAbort == VK_F8)
  356.                         wValue = IDD_AbortF8Flag ;
  357.                     else
  358.                         wValue = 0 ;  // none of the keys !!!
  359.             CheckRadioButton(hDlg, IDD_AbortEscFlag, IDD_AbortF8Flag, wValue) ;
  360.  
  361.             // If time limit isn't anabled, disable the time data part
  362.             CheckDlgButton(hDlg, IDD_TimeLimitFlag, (fValue = gCapParms.fLimitEnabled)) ;
  363.             EnableWindow(GetDlgItem(hDlg, IDD_SecondsText), fValue) ;
  364.             EnableWindow(GetDlgItem(hDlg, IDD_SecondsData), fValue) ;
  365.             if (fValue)
  366.                 SetDlgItemInt(hDlg, IDD_SecondsData, gCapParms.wTimeLimit, FALSE) ;
  367.             EnableWindow(GetDlgItem(hDlg, IDD_CapAudioFlag), gCapStatus.fAudioHardware) ;
  368.             CheckDlgButton(hDlg, IDD_CapAudioFlag, gCapParms.fCaptureAudio) ;
  369.             CheckDlgButton(hDlg, IDD_UseDOSMemFlag, gCapParms.fUsingDOSMemory) ;
  370.             CheckDlgButton(hDlg, IDD_CaptureOKFlag, gCapParms.fMakeUserHitOKToCapture) ;
  371.  
  372.             // Find out how many MCI devices can source video
  373.             if (CountMCIDevices(MCI_DEVTYPE_VCR) + 
  374.                 CountMCIDevices(MCI_DEVTYPE_VIDEODISC) == 0)
  375.                 // if no VCRs or Videodiscs, disable the controls
  376.                 fValue = FALSE ;
  377.             else
  378.                 fValue = TRUE ;
  379.  
  380.             // If no MCI device or MCI Control not enabled, disable MCI
  381.             // device name, start and stop time, step capture etc
  382.             EnableWindow(GetDlgItem(hDlg, IDD_MCIControlFlag), fValue) ;
  383.             CheckDlgButton(hDlg, IDD_MCIControlFlag,
  384.                            (fValue &= gCapParms.fMCIControl)) ;
  385.             EnableWindow(GetDlgItem(hDlg, IDD_MCIDeviceText), fValue) ;
  386.             EnableWindow(GetDlgItem(hDlg, IDD_MCIDeviceData), fValue) ;
  387.             SetDlgItemText(hDlg, IDD_MCIDeviceData, (LPSTR)gachMCIDeviceName) ;
  388.             EnableWindow(GetDlgItem(hDlg, IDD_MCIStartText), fValue) ;
  389.             EnableWindow(GetDlgItem(hDlg, IDD_MCIStartData), fValue) ;
  390.             EnableWindow(GetDlgItem(hDlg, IDD_MCIStopText), fValue) ;
  391.             EnableWindow(GetDlgItem(hDlg, IDD_MCIStopData), fValue) ;
  392.             if (fValue) {
  393.                 wsprintf((LPSTR)achBuffer, "%lu", gCapParms.dwMCIStartTime) ;
  394.                 SetDlgItemText(hDlg, IDD_MCIStartData, (LPSTR)achBuffer) ;
  395.                 wsprintf((LPSTR)achBuffer, "%lu", gCapParms.dwMCIStopTime) ;
  396.                 SetDlgItemText(hDlg, IDD_MCIStopData, (LPSTR)achBuffer) ;
  397.             }
  398.             EnableWindow(GetDlgItem(hDlg, IDD_MCIStepCapFlag), fValue) ;
  399.             CheckDlgButton(hDlg, IDD_MCIStepCapFlag, gCapParms.fStepMCIDevice) ;
  400.             SetDlgItemInt(hDlg, IDD_MaxDropData, gCapParms.wPercentDropForError, FALSE) ;
  401.             SetDlgItemInt(hDlg, IDD_VideoBuffData, gCapParms.wNumVideoRequested, FALSE) ;
  402.  
  403.             return TRUE ;
  404.         }
  405.  
  406.         case WM_COMMAND :
  407.             switch (wParam) {
  408.                 case IDD_TimeLimitFlag :
  409.                     // If this flag changes, en/dis-able time limit data part
  410.                     fValue = IsDlgButtonChecked(hDlg, IDD_TimeLimitFlag) ;
  411.                     EnableWindow(GetDlgItem(hDlg, IDD_SecondsText), fValue) ;
  412.                     EnableWindow(GetDlgItem(hDlg, IDD_SecondsData), fValue) ;
  413.                     return TRUE ;
  414.  
  415.                 case IDD_MCIControlFlag :
  416.                     // If this flag changes, en/dis-able MCI times data part
  417.                     fValue = IsDlgButtonChecked(hDlg, IDD_MCIControlFlag) ;
  418.                     EnableWindow(GetDlgItem(hDlg, IDD_MCIDeviceText), fValue) ;
  419.                     EnableWindow(GetDlgItem(hDlg, IDD_MCIDeviceData), fValue) ;
  420.                     EnableWindow(GetDlgItem(hDlg, IDD_MCIStartText), fValue) ;
  421.                     EnableWindow(GetDlgItem(hDlg, IDD_MCIStartData), fValue) ;
  422.                     EnableWindow(GetDlgItem(hDlg, IDD_MCIStopText), fValue) ;
  423.                     EnableWindow(GetDlgItem(hDlg, IDD_MCIStopData), fValue) ;
  424.                     EnableWindow(GetDlgItem(hDlg, IDD_MCIStepCapFlag), fValue) ;
  425.                     CheckDlgButton(hDlg, IDD_MCIStepCapFlag,
  426.                             gCapParms.fStepMCIDevice |
  427.                             IsDlgButtonChecked(hDlg, IDD_MCIStepCapFlag)) ;
  428.                     return TRUE ;
  429.  
  430.                 case IDOK :
  431.                 {
  432.                     int         iFrameRate ;
  433.                     int         iTimeLimit ;
  434.                     int         iMaxDropRate ;
  435.                     int         iVideoBuffers ;
  436.                     long        lMCIStart ;
  437.                     long        lMCIStop ;
  438.  
  439.                     if ((iFrameRate = (int) GetDlgItemInt(hDlg, IDD_FrameRateData, NULL,
  440.                                       TRUE)) <= 0 || iFrameRate >= 100) {
  441.                         // No frame at all or more than 100 FPS !!
  442.                         SetDlgItemInt(hDlg, IDD_FrameRateData, iFrameRate, TRUE) ;
  443.                         SetFocus(GetDlgItem(hDlg, IDD_FrameRateData)) ;
  444.                         MessageBeep(MB_ICONQUESTION) ;
  445.                         return FALSE ;
  446.                     }
  447.                     if (IsDlgButtonChecked(hDlg, IDD_TimeLimitFlag)) {
  448.                         if ((iTimeLimit = (int) GetDlgItemInt(hDlg, IDD_SecondsData, NULL,
  449.                                           TRUE)) <= 0 || iTimeLimit > 3600) {
  450.                             // No capture or more than 1 hour !!
  451.                             SetDlgItemInt(hDlg, IDD_SecondsData, iTimeLimit, TRUE) ;
  452.                             SetFocus(GetDlgItem(hDlg, IDD_SecondsData)) ;
  453.                             MessageBeep(MB_ICONQUESTION) ;
  454.                             return FALSE ;
  455.                         }
  456.                     }
  457.                     if (IsDlgButtonChecked(hDlg, IDD_MCIControlFlag)) {
  458.                         GetDlgItemText(hDlg, IDD_MCIStartData, (LPSTR)achBuffer, 20) ;
  459.                         lMCIStart = atol(achBuffer) ;
  460.                         if (lMCIStart < 0 ||             // negative time !!!
  461.                             lMCIStart >= 2000000000L) {  // or too high !!!
  462.                             SetDlgItemText(hDlg, IDD_MCIStartData, achBuffer) ;
  463.                             SetFocus(GetDlgItem(hDlg, IDD_MCIStartData)) ;
  464.                             MessageBeep(MB_ICONQUESTION) ;
  465.                             return FALSE ;
  466.                         }
  467.                         GetDlgItemText(hDlg, IDD_MCIStopData, (LPSTR)achBuffer, 20) ;
  468.                         lMCIStop = atol(achBuffer) ;
  469.                         if (lMCIStop < 0 ||            // negative time !!!
  470.                             lMCIStop >= 2000000000L || // or too high !!!
  471.                             lMCIStop < lMCIStart) {    // or Stop before Start !!!
  472.                             SetDlgItemText(hDlg, IDD_MCIStopData, achBuffer) ;
  473.                             SetFocus(GetDlgItem(hDlg, IDD_MCIStopData)) ;
  474.                             MessageBeep(MB_ICONQUESTION) ;
  475.                             return FALSE ;
  476.                         }
  477.                     }
  478.                     if ((iMaxDropRate = (int) GetDlgItemInt(hDlg, IDD_MaxDropData, NULL,
  479.                                             TRUE)) < 0 || iMaxDropRate >= 100) {
  480.                         // Negative drop limit or more than 100% !!
  481.                         SetDlgItemInt(hDlg, IDD_MaxDropData, iMaxDropRate, TRUE) ;
  482.                         SetFocus(GetDlgItem(hDlg, IDD_MaxDropData)) ;
  483.                         MessageBeep(0) ;
  484.                         return FALSE ;
  485.                     }
  486.                     if ((iVideoBuffers = (int) GetDlgItemInt(hDlg, IDD_VideoBuffData, NULL,
  487.                                              TRUE)) <= 0 || iVideoBuffers >= 32767) {
  488.                         // Can't capture with too many or without video buffers
  489.                         SetDlgItemInt(hDlg, IDD_VideoBuffData, iVideoBuffers, TRUE) ;
  490.                         SetFocus(GetDlgItem(hDlg, IDD_VideoBuffData)) ;
  491.                         MessageBeep(MB_ICONQUESTION) ;
  492.                         return FALSE ;
  493.                     }
  494.  
  495.                     // All the Cap params are correct. So set them now...
  496.                     gCapParms.dwRequestMicroSecPerFrame = (DWORD)(1E+6 / iFrameRate + 0.5) ;
  497.                     gCapParms.fLimitEnabled = IsDlgButtonChecked(hDlg, IDD_TimeLimitFlag) ;
  498.                     gCapParms.wTimeLimit = iTimeLimit ;
  499.                     if (gCapParms.fMCIControl =
  500.                             IsDlgButtonChecked(hDlg, IDD_MCIControlFlag)) {
  501.                         gCapParms.dwMCIStartTime = lMCIStart ;
  502.                         gCapParms.dwMCIStopTime  = lMCIStop ;
  503.                         GetDlgItemText(hDlg, IDD_MCIDeviceData, (LPSTR)achBuffer, 20) ;
  504.                         lstrcpy(gachMCIDeviceName, achBuffer) ;
  505.                         capSetMCIDeviceName(ghWndCap, gachMCIDeviceName) ;
  506.                         gCapParms.fStepMCIDevice = IsDlgButtonChecked(hDlg, IDD_MCIStepCapFlag) ;
  507.                     }
  508.                     else {
  509.                         gCapParms.dwMCIStartTime = gCapParms.dwMCIStopTime = 0 ;
  510.                         gCapParms.fStepMCIDevice = FALSE ;
  511.                     }
  512.                     // Lets yield while doing a step capture
  513.                     gCapParms.fYield = gCapParms.fStepMCIDevice;
  514.  
  515.                     gCapParms.wPercentDropForError = iMaxDropRate ;
  516.                     gCapParms.wNumVideoRequested = iVideoBuffers ;
  517.                     gCapParms.fAbortLeftMouse = IsDlgButtonChecked(hDlg, IDD_AbortLeftFlag) ;
  518.                     gCapParms.fAbortRightMouse = IsDlgButtonChecked(hDlg, IDD_AbortRightFlag) ;
  519.                     if (IsDlgButtonChecked(hDlg, IDD_AbortEscFlag))
  520.                         gCapParms.vKeyAbort = VK_ESCAPE ;
  521.                     else
  522.                         if (IsDlgButtonChecked(hDlg, IDD_AbortSpaceFlag))
  523.                             gCapParms.vKeyAbort = VK_SPACE ;
  524.                         else
  525.                             if (IsDlgButtonChecked(hDlg, IDD_AbortF8Flag))
  526.                                 gCapParms.vKeyAbort = VK_F8 ;
  527.                             else
  528.                                 gCapParms.vKeyAbort = 0 ;
  529.                     gCapParms.fCaptureAudio = 
  530.                                 IsDlgButtonChecked(hDlg, IDD_CapAudioFlag) ;
  531.                     gCapParms.fUsingDOSMemory = 
  532.                                 IsDlgButtonChecked(hDlg, IDD_UseDOSMemFlag) ;
  533.                     gCapParms.fMakeUserHitOKToCapture = 
  534.                                 IsDlgButtonChecked(hDlg, IDD_CaptureOKFlag) ;
  535.  
  536.                     EndDialog(hDlg, TRUE) ;
  537.                     return TRUE ;
  538.                 }
  539.  
  540.                 case IDCANCEL :
  541.                     EndDialog(hDlg, FALSE) ;
  542.                     return TRUE ;
  543.             }
  544.             break ; 
  545.     }
  546.  
  547.     return FALSE ;
  548. }
  549.